#include <iostream>
#include <algorithm>
using namespace std;

struct Node{
    int d, v, a;
}s[100005];

int maxx[100005], p[100005];

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while (T--){
        int n, m, L, V;
        cin >> n >> m >> L >> V;
        for (int i = 0; i < n; i++){
            cin >> s[i].d >> s[i].v >> s[i].a;
        }
        for (int i = 0; i < m; i++){
            cin >> p[i];
        }
        sort (p, p + m);
        int cnt=0, cnt2=0;
        for (int i = 0; i < n; i++){
            if (upper_bound(p, p + m, s[i].d) - p != m){
                if (s[i].v > V) cnt++;
            }
        }
        cout << cnt << ' ' << m - 1 << '\n';
    }
    return 0;
}
